package com.example.myapplication;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.bumptech.glide.load.resource.bitmap.CircleCrop;
import com.bumptech.glide.load.resource.bitmap.RoundedCorners;
import com.bumptech.glide.load.resource.drawable.DrawableTransitionOptions;
import com.bumptech.glide.request.RequestOptions;
import com.bumptech.glide.request.transition.DrawableCrossFadeFactory;
import com.example.module.GlideApp;

public class GlideActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_glide);
        TextView tv_recevice = findViewById(R.id.tv_recevice);
        ImageView img_glide = findViewById(R.id.img_glide);

        //发送消息
        Bundle bundle = getIntent().getExtras();
        String sendContent = bundle.getString("send_content");
        String url = bundle.getString("url");
        String desc = String.format("\n收到的请求：\n内容：%s\n来源:%s", sendContent, url);
        tv_recevice.setText(desc);

        //glide的使用
//        RequestOptions requestOptions = new RequestOptions()
//                .placeholder(R.drawable.sqrt)
//                .error(R.drawable.square_root_variable)
//                .fallback(R.drawable.square_root_variable);

        DrawableCrossFadeFactory factory = new DrawableCrossFadeFactory.Builder().setCrossFadeEnabled(true).build();

        Glide.with(GlideActivity.this)
                .load("https://img2.baidu.com/it/u=1980488535,891106663&fm=253&fmt=auto&app=138&f=JPEG?w=529&h=500")
                .transition(DrawableTransitionOptions.withCrossFade(factory))
                .transform(new RoundedCorners(100))
                .into(img_glide);

    }
}